<?php

namespace application\controller\cp;

use application\controller\cp\BaseController;
use application\entity\input\SiteSearch;
use application\service\SiteService;
use core\system\HttpRequest;

class SiteController extends BaseController {

    private $siteService;

    public function __construct() {
        parent::__construct();
        $this->view->layout = '/layout/main';
        $this->siteService = new SiteService();
    }

    /**
     * @module
     * @comment(Danh website)
     * @mapping(value=cp/site.html)
     */
    public function grid() {
        $search = HttpRequest::getRequest(SiteSearch::class);
        if (!isset($search->pageIndex) || $search->pageIndex < 0) {
            $search->pageIndex = 1;
        }
        $search->pageSize = 20;
        $this->view->search = $search;
        $this->view->dataPage = $this->siteService->search($search);
        $this->view->render('/site/grid');
    }

}
